Write OLE object to the file system

Hi,

I have a module with an attribute containing an OLE object (a file in a binary format). Is it possible to write the OLE as a file to the file system by DXL? It is possible to do it via drag and drop.

Cheers,
adar
SystemAdmin - Mon Jul 27 06:03:47 EDT 2009

Re: Write OLE object to the file system
fmercier - Mon Jul 27 09:00:33 EDT 2009

You can create a RTF file or a MS Word document for instance.
The first method is a bit tedious because you have to respect the RTF syntax. The second method is easier. Here is an example of the required code:

OleAutoObj WEXP_objWord = oleCreateAutoObject(cObjWordApplication)
OleAutoObj WEXP_objDocs = WEXP_objWord."Documents"

bool export2Word (Object o, string wordFileName)
{
// Make a new document
WEXP_objDocs->"Add"

// Get a handle on the document
OleAutoObj WEXP_objDoc = WEXP_objWord."ActiveDocument"
if (null WEXP_objDoc) return false

// Get a handle on the selection object
OleAutoObj WEXP_objSel = WEXP_objWord."Selection"
if (null WEXP_objSel) return false

// do the copy
if (!oleCopy o) return false

clear WEXP_objArgBlock
put(WEXP_objArgBlock, "Placement", wdInLine)
put(WEXP_objArgBlock, "DataType", wdPasteOLEObject)

string errMess = oleMethod(WEXP_objSel,"PasteSpecial",WEXP_objArgBlock)
if (!null errMess)
{
WEXP_objSel->"PasteSpecial" ("Placement"<-wdInLine)("DataType"<-wdPasteMetafilePicture)
}

// save the document
clear WEXP_objArgBlock
put(WEXP_objArgBlock, "FileName", wordFileName)

string msg = oleMethod(WEXP_objDoc, "SaveAs", WEXP_objArgBlock)
if ( msg != "" ) return false

// close the document
WEXP_objDoc->"Close"

return true
}

Re: Write OLE object to the file system
SystemAdmin - Mon Jul 27 09:08:32 EDT 2009

fmercier - Mon Jul 27 09:00:33 EDT 2009
You can create a RTF file or a MS Word document for instance.
The first method is a bit tedious because you have to respect the RTF syntax. The second method is easier. Here is an example of the required code:

OleAutoObj WEXP_objWord = oleCreateAutoObject(cObjWordApplication)
OleAutoObj WEXP_objDocs = WEXP_objWord."Documents"

bool export2Word (Object o, string wordFileName)
{
// Make a new document
WEXP_objDocs->"Add"

// Get a handle on the document
OleAutoObj WEXP_objDoc = WEXP_objWord."ActiveDocument"
if (null WEXP_objDoc) return false

// Get a handle on the selection object
OleAutoObj WEXP_objSel = WEXP_objWord."Selection"
if (null WEXP_objSel) return false

// do the copy
if (!oleCopy o) return false

clear WEXP_objArgBlock
put(WEXP_objArgBlock, "Placement", wdInLine)
put(WEXP_objArgBlock, "DataType", wdPasteOLEObject)

string errMess = oleMethod(WEXP_objSel,"PasteSpecial",WEXP_objArgBlock)
if (!null errMess)
{
WEXP_objSel->"PasteSpecial" ("Placement"<-wdInLine)("DataType"<-wdPasteMetafilePicture)
}

// save the document
clear WEXP_objArgBlock
put(WEXP_objArgBlock, "FileName", wordFileName)

string msg = oleMethod(WEXP_objDoc, "SaveAs", WEXP_objArgBlock)
if ( msg != "" ) return false

// close the document
WEXP_objDoc->"Close"

return true
}

Hi,

thank you for the quick answer.
I probably expressed myself a little misleading. I do not want to export the module. The module has a module attribute, which contains an OLE-Object. This OLE is a binary file (not a document but some proprietary file format). I want to export this file directly to the file system. I can do this by hand. I just open the module properties, double click the attribute and drag the OLE object somewhere into the file explorer. I just need to automate this process.

Cheers,
adar

Re: Write OLE object to the file system
UdoA - Thu Nov 19 09:57:41 EST 2009

Hello,

I have the same problem like adarmalik. Is there maybe a solutions available now?

Thanks,
Udo

Re: Write OLE object to the file system
doors36677 - Thu Nov 19 12:37:51 EST 2009

SystemAdmin - Mon Jul 27 09:08:32 EDT 2009
Hi,

thank you for the quick answer.
I probably expressed myself a little misleading. I do not want to export the module. The module has a module attribute, which contains an OLE-Object. This OLE is a binary file (not a document but some proprietary file format). I want to export this file directly to the file system. I can do this by hand. I just open the module properties, double click the attribute and drag the OLE object somewhere into the file explorer. I just need to automate this process.

Cheers,
adar

The subject has been address in several threads in either this forum or general forum -- to find search for the words: scrap file